<?php

namespace App\Modules\Admin\Services;

use App\Models\UploadGroup;

class FileGroupService extends BaseService
{
    public function __construct(UploadGroup $uploadGroup)
    {
        $this->model = $uploadGroup;
    }
    public function lists(array $params): array
    {
        // 分组不分页返回数据
        $params['is_download'] = 1;

        $params['where_callback'] = function($query) use ($params){
            $request = request();
            // 按照名称进行搜索
            if (!empty($search = $request->input('search', ''))){
                $query->where('group_name   ', 'LIKE', '%' . trim($search) . '%');
            }
        };
        $params['order'] = 'group_id';
        $params['order_sort'] = 'DESC';
        return parent::lists($params); // TODO: Change the autogenerated stub
    }
}
